﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Xiaov.SmartWeb.Model.ActiveRecord;
using Xiaov.SmartWeb.Infrastructure.ExtMethod;
using Xiaov.SmartWeb.Model;

namespace Xiaov.SmartWeb.Application.SysAdmin.Json
{
    public partial class UserModule : BasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            string cachekey = "S_GetUserModel_" + Page.User.Identity.Name;
            object menu = Xiaov.SmartWeb.Infrastructure.Cache.CacheFactroy.Instance().GetCache(cachekey);
            if (menu == null)
            {
                S_PM_MODULE module = new S_PM_MODULE();
                IList<S_PM_MODULE> list = module.GetModuleByUser(this.PUser.USERID).OrderBy(s => s.SORTBY).ToList();
                menu = list.ToDataTable().ToJsonForTree("MODULEID", "MODULENAME", "PARENTMODULEID", "0", "MODULEURL");
                Xiaov.SmartWeb.Infrastructure.Cache.CacheFactroy.Instance().SetCache(cachekey, menu);
            }
            Response.Clear();
            Response.Write(menu.ToString());
            Response.End();
        }
    }
}